import React from 'react'
import classNames from 'classnames'
import { Button } from 'antd-mobile'

import './submit-button.less'

const prefixCls = 'zhang-submit-btn'

class SubmitButton extends React.PureComponent {
  static defaultProps = {
    children: '确认',
    loadingText: '交易进行中...',
  }

  render() {
    const {
      loadingText,
      className,
      btnCls,
      ...others
    } = this.props

    const cls = classNames({
      [prefixCls]: true,
      [className]: className
    })

    return (
      <div className={cls}>
        {
          this.props.loading ? 
          <Button type='primary' className={btnCls} {...others} disabled={true}>
            {loadingText}
          </Button> : <Button type='primary' className={btnCls} {...others} />
        }
      </div>
    )
  }
}

export default SubmitButton